package com.kandinfo.base.security.authc;

import org.apache.shiro.authc.credential.DefaultPasswordService;
import org.apache.shiro.crypto.hash.DefaultHashService;
import org.apache.shiro.crypto.hash.format.HexFormat;
import org.apache.shiro.util.ByteSource;

public class NetEasePasswordService extends DefaultPasswordService {

	public NetEasePasswordService() {
		super();
		DefaultHashService hashServiceInstance = new DefaultHashService();
		hashServiceInstance.setHashAlgorithmName("MD5");
		super.setHashFormat( new HexFormat());
		super.setHashService(hashServiceInstance);
	}
	
	 public boolean passwordsMatch(Object submittedPlaintext, String saved) {
         return  super.passwordsMatch(submittedPlaintext, saved);
	 }
    protected ByteSource createByteSource(Object o) {
        return ByteSource.Util.bytes(o);
    }
    
    public static void main(String[] args){
    	NetEasePasswordService s  =  new NetEasePasswordService();
    	String pass = "123456"+Integer.toString("wxpay".substring(0,4).hashCode());
    	
    	System.out.println(s.encryptPassword(pass));
    }
}
